/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.qjs.smterp.model;

import java.util.Date;
import java.util.Set;

import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Vostro 3400
 */
@Entity
@Table(name = "tb_stock")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Stock.findAll", query = "SELECT s FROM Stock s"),
    @NamedQuery(name = "Stock.findByStockId", query = "SELECT s FROM Stock s WHERE s.stockId = :stockId"),
    @NamedQuery(name = "Stock.findByStockCode", query = "SELECT s FROM Stock s WHERE s.stockCode = :stockCode"),
    @NamedQuery(name = "Stock.findByStockName", query = "SELECT s FROM Stock s WHERE s.stockName = :stockName")})
public class Stock extends BasePojo {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    @Column(name = "STOCK_ID")
    private Integer stockId;
    @Basic(optional = false)
    @Column(name = "STOCK_CODE")
    private String stockCode;
    @Column(name = "STOCK_NAME")
    private String stockName;
    @Column(name = "STOCK_SIGNAL")
    private String stockSignal;
    @Column(name = "STOCKEEPER_ID")
    private Integer stockeeperId;
    @Column(name = "STOCKEEPER_NAME")
    private String stockeeperName;
    @Column(name = "BUILT_DATE")
    @Temporal(TemporalType.TIMESTAMP)
    private Date builtDate;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "AREA")
    private Float area;
    @Column(name = "STOCK_DETAIL_ID")
    private Integer stockDetailId;

    @OneToMany(cascade = CascadeType.ALL)
    @JoinColumn(name="STOCK_ID")
    private Set<GoodsInstock> goodsInstock;

    public Stock() {
    }

    public Stock(Integer stockId) {
        this.stockId = stockId;
    }

    public Stock(Integer stockId, String stockCode) {
        this.stockId = stockId;
        this.stockCode = stockCode;
    }

    public Integer getStockId() {
        return stockId;
    }

    public void setStockId(Integer stockId) {
        this.stockId = stockId;
    }

    public String getStockCode() {
        return stockCode;
    }

    public void setStockCode(String stockCode) {
        this.stockCode = stockCode;
    }

    public String getStockName() {
        return stockName;
    }

    public void setStockName(String stockName) {
        this.stockName = stockName;
    }

    public String getStockSignal() {
        return stockSignal;
    }

    public void setStockSignal(String stockSignal) {
        this.stockSignal = stockSignal;
    }

    public Integer getStockeeperId() {
        return stockeeperId;
    }

    public void setStockeeperId(Integer stockeeperId) {
        this.stockeeperId = stockeeperId;
    }

    public String getStockeeperName() {
        return stockeeperName;
    }

    public void setStockeeperName(String stockeeperName) {
        this.stockeeperName = stockeeperName;
    }

    public Date getBuiltDate() {
        return builtDate;
    }

    public void setBuiltDate(Date builtDate) {
        this.builtDate = builtDate;
    }

    public Float getArea() {
        return area;
    }

    public void setArea(Float area) {
        this.area = area;
    }

    public Integer getStockDetailId() {
        return stockDetailId;
    }

    public void setStockDetailId(Integer stockDetailId) {
        this.stockDetailId = stockDetailId;
    }

    public Set<GoodsInstock> getGoodsInstock() {
		return goodsInstock;
	}

	public void setGoodsInstock(Set<GoodsInstock> goodsInstock) {
		this.goodsInstock = goodsInstock;
	}

	@Override
    public int hashCode() {
        int hash = 0;
        hash += (stockId != null ? stockId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Stock)) {
            return false;
        }
        Stock other = (Stock) object;
        if ((this.stockId == null && other.stockId != null) || (this.stockId != null && !this.stockId.equals(other.stockId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.qjs.smterp.model.Stock[ stockId=" + stockId + " ]";
    }
    
}
